package com.yunfei.api.v1.magerIndcInfo.service.impl;
import com.yunfei.api.v1.directionary.result.CardTypeResultBo;
import com.yunfei.api.v1.magerIndcInfo.contants.MagerIndcInfoContant;
import com.yunfei.api.v1.magerIndcInfo.param.TemplateManagerParam;
import com.yunfei.api.v1.magerIndcInfo.result.FaRenInfoResult;
import com.yunfei.api.v1.magerIndcInfo.service.MagerIndcInfoService;
import com.yunfei.mapper.aiiidb.FaRenInfoMapper;
import com.yunfei.mapper.aiiidb.MagerIndcInfoMapper;
import com.yunfei.mapper.aiiidb.MagerIndcInfoTemplateMapper;
import com.yunfei.yunhetong.magerIndeInfo.entity.MagerIndcInfoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @program: springclould_ylcaifu_App
 * @description:
 * @author: zhengyunfei
 * @create: 2019-08-02 14:49
 **/
@Service("magerIndcInfoService")
public class MagerIndeInfoImpl implements MagerIndcInfoService {
    @Autowired
    private MagerIndcInfoTemplateMapper magerIndcInfoTemplateMapper;
    @Autowired
    private MagerIndcInfoMapper magerIndcInfoMapper;
    @Autowired
    private FaRenInfoMapper faRenInfoMapper;
    @Override
    public void add(TemplateManagerParam param) {
        String type=param.getType();//类型
        String fileName=param.getFileName();
        String fileUrl=param.getFileUrl();
        String fileId=param.getFileId();
        String operatorId=param.getOperatorId();
        String caCustId=param.getCaCustId();
        if(caCustId.contains("\"")){
            caCustId=caCustId.replace("\"","");
        }
        param.setCaCustId(caCustId);
        //E1:合同模板添加
        if(MagerIndcInfoContant.TEMPLATE_TYPE_E1.equals(type)){
            magerIndcInfoTemplateMapper.addHeTongMuBan(param);
        }
        //E2:合同模板删除
        if(MagerIndcInfoContant.TEMPLATE_TYPE_E2.equals(type)){
            magerIndcInfoTemplateMapper.delHeTongMuBan(param);
        }
        //F1:管理人公章添加
        if(MagerIndcInfoContant.TEMPLATE_TYPE_F1.equals(type)){
            magerIndcInfoTemplateMapper.addGuanLiRenGongZhang(param);
        }
        //F2:管理人公章删除
        if(MagerIndcInfoContant.TEMPLATE_TYPE_F2.equals(type)){
            magerIndcInfoTemplateMapper.delGuanLiRenGongZhang(param);
        }
        //G1:法定代表人/授权代表章添加
        if(MagerIndcInfoContant.TEMPLATE_TYPE_G1.equals(type)){
            magerIndcInfoTemplateMapper.addFaDingDaiBiao(param);
        }
        //G2:法定代表人/授权代表章删除
        if(MagerIndcInfoContant.TEMPLATE_TYPE_G2.equals(type)){
            magerIndcInfoTemplateMapper.delFaDingDaiBiao(param);
        }
        //H1：作废协议模板添加
        if(MagerIndcInfoContant.TEMPLATE_TYPE_H1.equals(type)){
            magerIndcInfoTemplateMapper.addZuoFeiXieYiMuBan(param);
        }
        //H2：作废协议模板删除
        if(MagerIndcInfoContant.TEMPLATE_TYPE_H2.equals(type)){
            magerIndcInfoTemplateMapper.delZuoFeiXieYiMuBan(param);
        }
    }

    @Override
    public MagerIndcInfoEntity findByMap(Map<String, Object> queryMap) {
        MagerIndcInfoEntity magerIndcInfoEntity= (MagerIndcInfoEntity) magerIndcInfoMapper.findByMap(queryMap);
        return magerIndcInfoEntity;
    }

    @Override
    public FaRenInfoResult getFaRenInfo(Map<String, Object> queryMap) {
        return faRenInfoMapper.getFaRenInfo(queryMap);
    }
    @Override
    public List<CardTypeResultBo> getCardType(Map<String, Object> queryMap) {
        return faRenInfoMapper.getCardType(queryMap);
    }
}
